package com.example.demo.service.impl;

import com.example.demo.dataobject.Food;
import com.example.demo.repository.FoodRepository;
import com.example.demo.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {

    @Autowired
    private FoodRepository foodRepository;

    @Override
    public List<Food> findByFoodType(Integer foodType) {
        List<Food> result = foodRepository.findByFoodType(foodType);
        return result;
    }

    @Override
    public List<Food> findByFoodTypeOrderByCarbonWater(Integer foodType) {
        List<Food> result=foodRepository.findByFoodTypeOrderByCarbonWater(foodType);
        return result;
    }

    @Override
    public List<Food> findByFoodTypeOrderByCarbonWaterDesc(Integer foodType) {
        List<Food> result=foodRepository.findByFoodTypeOrderByCarbonWaterDesc(foodType);
        return result;
    }

    @Override
    public List<Food> findByFoodNameLikeOrderByCarbonWater(String foodName) {
        List<Food> result = foodRepository.findByFoodNameLikeOrderByCarbonWater(foodName);
        return result;
    }
}
